package base.day19.array;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Collection2 {
    public static void main(String[] args) {
        Collection<String> list=new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        list.add("e");

        //获取迭代器的对象
        Iterator<String> it=list.iterator();
        //hasNext 判断是否有元素可以被取出
        System.out.println(it.hasNext());
        for (int i = 0; i < list.size(); i++) {
            //next 取出当前元素，迭代器的索引位置+1
            System.out.println(it.next());
        }

        while (it.hasNext()){
            System.out.println(it.next());
        }


    }
}
